/**
 * User.java
 *
 *
 * $LastChangedBy: allen $
 * $LastChangedDate: 2007-12-12 12:39:22 +0800 $
 * $Revision: 1445 $
 */
package com.myspace.domain;

import java.util.Date;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

@Entity(name = "User")
@Table(name = "USER_INFO")
public class User extends DomainObject
{
	private static final long serialVersionUID = 20071116L;
	private Long id;
	private String name;
	private String dispName;
	private String password;
	private byte[] photo;
	private int gender = 1;
	private Date birthday;
	private Date updateDate;
	private int clicks;
	private String phone;
	private List<Picture> pictures;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "seq_user_info")
	@SequenceGenerator(name = "seq_user_info", sequenceName = "SEQ_USER_INFO")
	public Long getId()
	{
		return id;
	}

	void setId(Long id)
	{
		this.id = id;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	@Column(name = "DISP_NAME")
	public String getDispName()
	{
		return dispName;
	}

	public void setDispName(String dispName)
	{
		this.dispName = dispName;
	}

	public String getPassword()
	{
		return password;
	}

	public void setPassword(String password)
	{
		this.password = password;
	}

	@Basic(fetch = FetchType.EAGER)
	public byte[] getPhoto()
	{
		return photo;
	}

	public void setPhoto(byte[] photo)
	{
		this.photo = photo;
	}

	public int getGender()
	{
		return gender;
	}

	public void setGender(int gender)
	{
		this.gender = gender;
	}

	public Date getBirthday()
	{
		return birthday;
	}

	public void setBirthday(Date birthday)
	{
		this.birthday = birthday;
	}

	@Temporal(TemporalType.TIMESTAMP)
	public Date getUpdateDate()
	{
		return updateDate;
	}

	public void setUpdateDate(Date updateDate)
	{
		this.updateDate = updateDate;
	}

	public int getClicks()
	{
		return clicks;
	}

	public void setClicks(int clicks)
	{
		this.clicks = clicks;
	}

	public String getPhone()
	{
		return phone;
	}

	public void setPhone(String phone)
	{
		this.phone = phone;
	}

	@OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	public List<Picture> getPictures()
	{
		return pictures;
	}

	public void setPictures(List<Picture> pictures)
	{
		this.pictures = pictures;
	}

	@Override
	@Transient
	public boolean isPersistence()
	{
		return id != null;
	}
}
